package ubi.quando.UI;

import java.util.List;

import ubi.quando.App.Contact;
import ubi.quando.App.EventBase;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TableLayout;
import android.widget.TextView;

public abstract class AddParticipantsBaseActivity extends Activity {
	protected UbiApplication mApp;
	protected EventBase mEvent;

	protected ListView mListView;
	protected AutoCompleteTextView mTextView;
	protected Button mOkBtn;
	protected Button mCancelBtn;
	protected TableLayout mTableView;
	private TextView mTxt1;

	protected List<Contact> mContacts;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.add_participants);

		mApp = (UbiApplication) getApplication();
		mApp.setCurrentActivity(this);

		mContacts = getContactNames();

		InitViewMembers();

		InitListeners();
	}

	protected void initFont() {
		Typeface font = Typeface.createFromAsset(getAssets(), "AGENCYR.TTF");
		mTxt1.setTypeface(font);
		mTextView.setTypeface(font);
		mOkBtn.setTypeface(font);
		mCancelBtn.setTypeface(font);

	}

	protected void InitViewMembers() {
		mTextView = (AutoCompleteTextView) findViewById(R.id.autocomplete_participants);
		mTableView = (TableLayout) findViewById(R.id.tl_participantsTable);
		mListView = (ListView) findViewById(R.id.listview_participants);
		mOkBtn = (Button) findViewById(R.id.btn_confirm);
		mCancelBtn = (Button) findViewById(R.id.btn_cancel);
		mTxt1 = (TextView) findViewById(R.id.contact_name);

		ArrayAdapter<Contact> adapter = new ArrayAdapter<Contact>(this,
				R.layout.autocmp_list_item, mContacts);
		mTextView.setAdapter(adapter);
	}

	private List<Contact> getContactNames() {
		return mApp.getContacts();
	}

	protected abstract void InitListeners();
}
